function getData(endpoint, cb) {
    const XHR = new XMLHttpRequest();
    XHR.open("GET", endpoint);

    XHR.onreadystatechange = function () {
        if ((this.readyState === 4) & (this.status === 200)) {
            cb(JSON.parse(this.responseText));

            //console.log(JSON.parse(this.responseText));
        }
    };

    setTimeout(() => {
        XHR.send();
    }, Math.floor(Math.random() * 3000) + 1000);
}

getData('./movies.json', (data) => {
    console.log(data);
    getData('./actors.json', (data) => {
        console.log(data);
    getData('./directors.json', (data) => {
        console.log(data);
    });
  });
});